package Games.PumpGame.Gui
{
	import flash.display.DisplayObject;
	import flash.text.TextField;
	import Framework.BaseGui;
	import flash.text.TextFieldAutoSize;
	
	/**
	 * ...
	 * @author Menno
	 */
	public class PriceCard extends BaseGui
	{
		private var _price:Array;
		private var _x:int;
		private var _y:int;
		private var _size:int;
		private var _textFieldStorage:Array;
		
		public function PriceCard(x:int, y:int, size:int) 
		{
			_size = size;
			_y = y;
			_x = x;
			
			_price = new Array();
			_textFieldStorage = new Array();
		}
		
		override public function draw():void 
		{
			if (_price.length == 0)
			{
				 return;
			}
			
			if (_textFieldStorage.length == 0)
			{
				for (var j:int = 0; j< price.length; j++)
				{
					_textFieldStorage[j] = new TextField();
					this.addChild(_textFieldStorage[j]);
				}
			}
			
			super.draw();
			graphics.clear();
			for (var i:int = 0; i < price.length; i++)
			{
				
				graphics.lineStyle(1, 0x000000);
				if (i == price.length - 1)
				{
					graphics.beginFill(0x44FF9B);	
				}
				else
				{
					graphics.beginFill(0xFFFFFF);					
				}

				graphics.drawRect(0 + _size * i, 0, _size, _size);
				graphics.endFill();
				
				var curPrice:String = price[(price.length - i - 1)];
				_textFieldStorage[i].text = "" + curPrice;
				
				_textFieldStorage[i].x = 0 + _size * i
				_textFieldStorage[i].width = _textFieldStorage[i].height = _size;
				
				_textFieldStorage[i].autoSize = TextFieldAutoSize.CENTER;
				_textFieldStorage[i].y = (_size / 2) - (_textFieldStorage[i].textHeight / 2);
			}
			this.x = _x;
			this.y = _y;
		}

		//////////////////////////////////////////////////
		//												//
		// 				PROPERTIES						//
		//												//
		//////////////////////////////////////////////////			
		
		public function get price():Array 
		{
			return _price;
		}
		
		public function set price(value:Array):void 
		{
			_price = value;
		}
	}
	
}